<ion-view view-title="销售订单" class="home-view">
    <ion-content on-scroll="hideKeyboard()">
        <ion-list class="order-list">
            <ion-item ng-repeat="order in data.orders" class="item order-item">
                <img id="giveaway{{$index}}" ng-src="{{'img/giveaway.png'}}" style="position: absolute;top: 6px;left: 10px;width: 100%;max-width: 60px;height: 100%;max-height: 60px;border-radius: 8%;">
                <img class="goodsIcon" ng-src="{{order.picture || 'img/default.png'}}">

                <div class="midMsg">
                    <div class="orderMerchandiseName">{{order.name}}</div>
                    <div class="orderMerchandiseSpec">{{"("+order.spec+")"}}</div>
                    <div class="orderMerchandisePrice">
                    {{order.symbols?order.symbols:'￥'}}:
                    {{order.price}}元/
                    {{order.unit?order.unit:'无单位'}}
                    </div>
                </div>
                <div class="rightMsg">
                    <span class="reduce ion-ios-minus-empty" ng-click="raiseOrReduce(order,'reduce')"></span>
                    <input class="numInput" type="number" ng-change="numChg(order)" ng-model="order.num" required/>
                    <span class="raise ion-ios-plus-empty" ng-click="raiseOrReduce(order,'raise')"></span>

                    <p class="subtotal">小计:
                    {{order.giveawayChecked ? 0 : order.subtotal}}元
                    </p>
                </div>
                <ion-option-button class="order-giveaway" 
                style="background-color: #ddd;;color: white;font-weight: normal;"
                ng-show="!order.giveawayChecked" ng-click="markGiveaway($index,true,order)">
                <img src="img/giveaway+.png" style="width: 75px;height: 100%;">
                </ion-option-button>

                <ion-option-button class="order-giveaway" 
                style="background-color: #ddd;;color: white;font-weight: normal;"
                ng-show="order.giveawayChecked" ng-click="markNoGiveaway($index,false,order)">
                <img src="img/giveaway-.png" style="width: 75px;height: 100%;">
                </ion-option-button>

                <ion-option-button class="order-trash"
                style="background-color: #EC6B6B;color: white;font-weight: normal;"ng-click="trashOrder(order)">
                删除
                </ion-option-button>

            </ion-item>
        </ion-list>
        <div>
            <form action="">
                <div class="list">
                    <label class="item item-input">
                        <span class="input-label">业务员</span>
                        <span class="spanMsg">{{data.divisions.userName}}&nbsp&nbsp&nbsp
                            <i>{{data.divisions.division.name}}</i>
                        </span>
                    </label>

                    <label class="item item-input" ng-click="resetContact()">
                        <span class="input-label">客户信息</span>
                        <span class="spanMsg">{{data.contact.Name}}&nbsp&nbsp&nbsp
                            <i>{{data.contact.AddressName}}</i>
                        </span>
                        <span class="selectIcon ion-ios-arrow-right"></span>
                    </label>

                    <label class="item item-input" on-tap="selectDate()">
                        <span class="input-label">收货日期</span>
                        <span class="spanMsg">{{data.receiptDate}}</span>
                        <span class="selectIcon ion-ios-arrow-right"></span>
                    </label>

                    <label class="item item-input">
                        <span class="input-label">备忘录</span>
                        <textarea style="border: 1px #EAE6E6 solid;width: 70%;" ng-model="data.mark"></textarea>
                    </label>
                </div>
            </form>
        </div>
    </ion-content>
    <ion-footer-bar class="bar bar-footer order-footer" style="border-top: 1px solid #e0e0e0;padding: 0">
        <div class="tip">订单信息</div>
        <div class="totle">合计：
            <span class="totalMoney">￥:{{data.totalMoney}}元</span>
        </div>
        <button class="goPayOrder" ng-click="buyOrders(data.orders)">下单({{data.count}})</button>
    </ion-footer-bar>
</ion-view>